package com.r2coding.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author: 98k灬
 * @since: 2022/10/31
 * @email: 98k_style@sina.com
 * @公众号: 爪哇Guy灬
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result implements Serializable {
    /**
     * 状态码
     */
    private Integer code;

    /**
     * 消息提示
     */
    private String message;

    /**
     * 返回的数据
     */
    private Object data;

    public static Result ok() {
        return ok(null);
    }

    public static Result ok(Object data) {
        return ok("success", data);
    }

    public static Result ok(String message, Object data) {
        return new Result(200, message, data);
    }

    public static Result error(String message) {
        return build(500, message);
    }

    public static Result build(Integer code, String message) {
        return new Result(code, message, null);
    }
}
